package com.micangcaihang.micang.util;

import android.app.Activity;

import com.afollestad.materialdialogs.MaterialDialog;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/8/18
 *     update : 2017/8/18
 *     desc   : MiCang
 *     version: 1.0
 * </pre>
 */
public class DialogHelper {
    public static void showSaveDialog(Activity activity, OnPositiveListenner onPositiveListenner, OnNegativeListenner onNegativeListenner) {
        new MaterialDialog.Builder(activity)
                .content("检测到您更改了当前页面的内容,点击保存立即保存当前页面内容,点击不保存则切换至下一页面")
                .positiveText("保存")
                .negativeText("不保存")
                .onPositive((dialog, which) -> {
                    dialog.dismiss();
                    onPositiveListenner.onPositive();
                })
                .onNegative((dialog, which) -> {
                    dialog.dismiss();
                    onNegativeListenner.onNegative();
                })
                .show();
    }

    public static void showDeleteUserDialog(Activity activity, String title, OnPositiveListenner onPositiveListenner) {
        new MaterialDialog.Builder(activity)
                .content(title)
                .positiveText("确定")
                .negativeText("取消")
                .onPositive((dialog, which) -> {
                    dialog.dismiss();
                    onPositiveListenner.onPositive();
                })
                .onNegative((dialog, which) -> {
                    dialog.dismiss();
                })
                .show();
    }

    public interface OnPositiveListenner {
        void onPositive();
    }

    public interface OnNegativeListenner {
        void onNegative();
    }
}
